package com.sec.android.app.myfiles.mockclass;

import android.app.Activity;
import android.content.Intent;

import org.mockito.ArgumentCaptor;
import org.powermock.api.mockito.PowerMockito;

import java.util.List;

import static org.powermock.api.mockito.PowerMockito.doNothing;

/**
 * Created by jaebae on 2016-07-01.
 */
public class ActivityMock {
    static ArgumentCaptor<Intent> sCaptor = ArgumentCaptor.forClass(Intent.class);

    public static Intent getStartActivityIntent() {
        List<Intent> list = sCaptor.getAllValues();
        Intent ret = null;
        if (list != null && !list.isEmpty()) {
            ret = list.get(0);
            list.clear();
        }
        return ret;
    }

    public static Activity createMock() {
        Activity activityMock = PowerMockito.mock(Activity.class);
        doNothing().when(activityMock).startActivity(sCaptor.capture());
        return activityMock;
    }
}
